package com.simple.utils;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.data.domain.Page;

import com.alibaba.fastjson.JSONObject;

public class TableUtils {
	
	public static JSONObject tableResult(List list){
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("code", 0);
		map.put("msg", "ok");
		map.put("count",list.size());
		map.put("data", list);
		JSONObject jsonObject=new JSONObject(map);
		return jsonObject;
	}
	
	public static JSONObject tablePageResult(Page page){
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("code", 0);
		map.put("msg", "ok");
		map.put("count", page.getTotalElements());
		map.put("data", page.getContent());
		JSONObject jsonObject=new JSONObject(map);
		return jsonObject;
	}
	
	
	

}
